var path = require('path');
var webpack = require('webpack');

module.exports = {
  // 入口
  entry: './src/index',
  // 输出
  output: {
    path: path.join(__dirname, './dist'),
    filename: '[name].js',
    publicPath: '/dist/'
  },
  module: {
    // 加载器
    loaders: [
      { test: /\.vue$/, loader: 'vue' },
      { test: /\.js$/, loader: 'babel', exclude: /node_modules/ },
      { test: /\.css$/, loader: 'style!css!autoprefixer' },
      { test: /\.less/, loader: 'style!css!autoprefixer!less' },
      { test: /\.(png|jpg|gif)$/, loader: 'url-loader' },
      { test: /\.(html|tpl)$/, loader: 'html-loader' },
    ]
  },
  vue: {
    loaders: {
      css: 'style!css!autoprefixer!less'
    }
  },
  babel: {
    presets: ['es2015'],
    plugins: ['transform-runtime']
  },
  resolve: {
    // require时省略的扩展名，如：require('module') 不需要module.js
    extensions: ['', '.js', '.vue'],
  },
  // 开启source-map，webpack有多种source-map，在官网文档可以查到
  devtool: '#source-map',
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('common.js'),
    new webpack.optimize.OccurenceOrderPlugin(),
  ]
};
